function wallRefresh()

{
	$.ajax({
		url: "tmp/wall.json",
		type: 'GET',
		dataType: 'json', 
		data: { },
		success: function(myData) {
			
		},
		error: function(jqXHR, textStatus, errorThrown) {
			
		}
	});
}


$(document).ready(function() {
	$("#wallForm").submit(function(e) {
		e.preventDefault();
		return false;
	});
	$(".comment_button").click(function() {
		var element = $(this);
		var boxval = $("#update_box_content").val();
		var dataString = 'update_box_content='+ boxval;

		if(boxval=='')
			alert("Please Enter Some Text");
		else {
			$("#flash").show();
			$("#flash").fadeIn(400).html('<img src="ajax.gif" align="absmiddle">&nbsp;<span class="loading">Loading Update...</span>');
			/*$.ajax({
				type: "POST",
	  			url: "update_ajax.php",
	   			data: dataString,
	  			cache: false,
	  			success: function(html){
	  				$("ol#update").prepend(html);
	  				$("ol#update li:first").slideDown("slow");
	   				document.getElementById('content').value='';
	   				$('#content').value='';
	   				$('#content').focus();
	  				$("#flash").hide();
	  			}
	 		});*/
			var myCurrentTimestamp = Math.round((new Date()).getTime() / 1000);
			var myListItem = $('<li>');
			myListItem.addClass('bar' + myCurrentTimestamp);
			var myPostBox = $('<div>');
			myPostBox.addClass('post_box');
			myPostBox.append('<span>' + boxval + '</span>');
			myPostBox.append('<span class="delete_button"><a href="#" id="' + myCurrentTimestamp + '" class="delete_update">X</a></span>');
			myPostBox.append('<span class="feed_link"><a href="#" class="comment" id="' + myCurrentTimestamp + '">comment</a></span>');
			myListItem.append(myPostBox);
			var myFullBox = $('<div>');
			myFullBox.addClass('fullbox' + myCurrentTimestamp);
			myFullBox.append('<div id="commentload' + myCurrentTimestamp + '">');
			var myCommentBox = $('<div class="comment_box" id="c' + myCurrentTimestamp + '">');
			var myCommentForm = $('<form method="post" action="" name="' + myCurrentTimestamp + '">');
			myCommentForm.append('<textarea class="text_area" name="comment_value" id="textarea' + myCurrentTimestamp + '"></textarea><br />');
			myCommentForm.append('<input type="submit" value=" Comment " class="comment_submit" id="' + myCurrentTimestamp + '"/>');
			myCommentBox.append(myCommentForm);
			myFullBox.append(myCommentBox);
			myListItem.append(myFullBox);
			$("ol#update").prepend(myListItem);
			$("ol#update li:first").slideDown("slow");
			document.getElementById('update_box_content').value='';
			$('#update_box_content').value='';
			$('#update_box_content').focus();
			$("#flash").hide();
		}
	
		return false;
	});


	// delete update
	$('.delete_update').live("click",function(e) {
		e.preventDefault();
		var ID = $(this).attr("id");
		if(confirm("Êtes-vous sûr? Pas de Control-Z ici!"))
			$(".bar"+ID).slideUp();
		return false;
	});

	//comment slide
	$('.comment').live("click",function(e) {
		e.preventDefault();
		var ID = $(this).attr("id");
		$(".fullbox"+ID).show();
		$("#c"+ID).slideToggle(300);
		return false;
	});

	//commment Submit
	$('.comment_submit').live("click",function(e) {
		e.preventDefault();
		var ID = $(this).attr("id");
		var comment_content = $("#textarea"+ID).val();
		var dataString = 'comment_content='+ comment_content;
    	
		if(comment_content=='')
			alert("Merci d'entrer du texte dans votre commentaire.");
		else {
			/*$.ajax({
				type: "POST",
		  		url: "comment_ajax.php",
		   		data: dataString,
		  		cache: false,
		  		success: function(html){
					$("#commentload"+ID).append(html);
		    		document.getElementById("textarea"+ID).value='';
		   			$("#textarea"+ID).focus();
		  		}
		 	});*/
			var myCurrentTimestamp = Math.round((new Date()).getTime() / 1000);
			var myCommentContainer = $('<div class=comment_load id="comment' + myCurrentTimestamp + '">');
			myCommentContainer.text(comment_content);
			myCommentContainer.append('<span class="cdelete_button"><a href="#" id="' + myCurrentTimestamp + '" class="cdelete_update">X</a></span>');
			$("#commentload"+ID).append(myCommentContainer);
    		document.getElementById("textarea"+ID).value='';
   			$("#textarea"+ID).focus();
		}	
		
		return false;
	});
	
	//comment delete
	$('.cdelete_update').live("click",function(e) {
		e.preventDefault();
		var ID = $(this).attr("id");
		if(confirm("Êtes-vous sûr? Pas de Control-Z ici!"))
			$("#comment"+ID).slideUp();
		return false;
	});
	
	//wallRefresh();
});